<?php

namespace app\common\model;

use app\common\model\BaseModel as BaseModel;

/**
 * Class LawCase
 * @package app\common\model
 * @property int $id
 * @property int $questionId
 * @property int $memberId
 * @property int $creatorId
 * @property int $creatorMemberType
 * @property string $ask
 * @property int $categoryId
 * @property float $moneyId
 * @property int $provinceId
 * @property int $cityId
 * @property string $phone
 * @property int $alwaysLive
 * @property int $isSelf
 * @property int $daysId
 * @property int $employLawyer
 * @property int $isPublish
 * @property int $publishTime
 * @property int $status
 * @property int $buyType
 * @property float $totalPrice
 * @property float $price
 * @property int $num
 * @property int $surplus
 * @property float $creatorShareRate
 * @property string $aryStatus
 * @property int $aryTime
 * @property string $aryCode
 * @property string $aryMsg
 * @property int $updated
 * @property int $created
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037579
 * @link https://www.kancloud.cn/manual/think-orm/1257998
 * @link https://www.kancloud.cn/thinkphp/master-database-and-model/265551
 */
class LawCase extends BaseModel
{
    // 案如云推送状态 UNPUSH 未推送 PUSHING 推送中 PUSHED 已推送 PUSH_FAILED
    const UNPUSH = ConsultingQuestion::UNPUSH;
    const PUSHING = ConsultingQuestion::PUSHING;
    const PUSHED = ConsultingQuestion::PUSHED;
    const PUSH_FAILED = ConsultingQuestion::PUSH_FAILED;

    protected $name = 'LawCase';

    // 案件类型
    public function category()
    {
        return $this->belongsTo(LawCaseCategory::class, 'categoryId', 'id');
    }

    // 提问人
    public function member()
    {
        return $this->belongsTo(Member::class, 'memberId', 'id');
    }

    // 发布人
    public function creator()
    {
        return $this->belongsTo(Member::class, 'creatorId', 'id');
    }

    public function province()
    {
        return $this->hasOne(\app\common\model\Area::class, 'id', 'provinceId');
    }

    public function city()
    {
        return $this->hasOne(Area::class, 'id', 'cityId');
    }

    public function money()
    {
        return $this->hasOne(LawCaseMoney::class, 'id', 'moneyId');
    }

    public function days()
    {
        return $this->hasOne(LawCaseDays::class, 'id', 'daysId');
    }

    public function trades()
    {
        return $this->hasMany(Trade::class, 'lawCaseId', 'id');
    }

    /**
     * 1对1
     * @return \think\model\relation\HasOne
     */
    //    public function one(){
    //        return $this->hasOne( Test1::class, 'Test1表中的键', 'LawCase表中的键');
    //    }

    /**
     * 1对多
     * @return \think\model\relation\HasMany
     */
    //    public function many(){
    //        return $this->hasMany( Test1::class, 'Test1表中的键', 'LawCase表中的键');
    //    }

    /**
     * 多对多
     * @return \think\model\relation\BelongsToMany
     */
    //    public function belongs(){
    //        return $this->belongsToMany( Test1::class, '中间表', '中间表中Test1的键', '中间表中LawCase的键');
    //    }
}
